package com.rain.cy.business.handler;

import com.rain.cy.business.handler.base.BaseProcessHandler;
import com.rain.cy.business.handler.base.ProcessHandler;
import com.rain.cy.business.model.dto.UserProcessDataDTO;
import com.rain.cy.business.model.json.BaseProcessDataJson;
import com.rain.cy.business.model.json.ProcessOneOfDataJson;
import com.rain.cy.business.model.json.ProcessTwoOfDataJson;
import com.rain.cy.business.service.UserProcessStatusService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Collections;

/**
 * @author yu_chen
 * @since 2021/10/10 17:41
 */
@Component
public class ProcessTwoHandler extends BaseProcessHandler {

    @Autowired
    private UserProcessStatusService userProcessStatusService;

    @Override
    public BaseProcessDataJson initProcessDataJson() {
        ProcessTwoOfDataJson processOneOfDataJson=new ProcessTwoOfDataJson();
        processOneOfDataJson.setSuggestOfDoctor("");
        processOneOfDataJson.setReportInfo("");
        processOneOfDataJson.setTreatmentIntro("");
        return processOneOfDataJson;
    }

    @Override
    public void handler(UserProcessDataDTO userProcessDataDTO) {
        Integer userId = userProcessDataDTO.getUserId();
        ProcessTwoOfDataJson processDataJson = (ProcessTwoOfDataJson) userProcessDataDTO.getBaseProcessDataJson();
        if (processDataJson == null) {
            return;
        }
        if (StringUtils.isNotEmpty(processDataJson.getReportInfo())) {
            userProcessStatusService.updateUserProcessStatus(userId, "2001");
        }
        if (StringUtils.isNotEmpty(processDataJson.getSuggestOfDoctor())) {
            userProcessStatusService.updateUserProcessStatus(userId, "2003");
        }
        if (StringUtils.isNotEmpty(processDataJson.getTreatmentIntro())) {
            userProcessStatusService.updateUserProcessStatus(userId, "2002");
        }
        userProcessStatusService.updateUserProcessStatus(userId, "30");
    }

}
